package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.realname.dto.RealnameDto;
import com.zhentao.model.realname.pojo.ApRealname;
import com.zhentao.service.ApRealnameService;
import freemarker.template.TemplateException;
import io.minio.errors.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping("/api/v1/app/realname")
@Api(tags = "UserAppRealnameController-app用户实名上传管理")
public class UserAppRealnameController {
    @Resource
    ApRealnameService apRealnameService;

    /**
     * app用户实名信息上传
     * @param apRealname
     * @return
     * @throws ServerException
     * @throws TemplateException
     * @throws InvalidBucketNameException
     * @throws InsufficientDataException
     * @throws ErrorResponseException
     * @throws IOException
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeyException
     * @throws InvalidResponseException
     * @throws XmlParserException
     * @throws InternalException
     */
    @ApiOperation("app用户实名信息上传")
    @PostMapping("/add")
    public ResponseResult add(@RequestBody ApRealname apRealname) throws ServerException, TemplateException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return apRealnameService.add(apRealname);
    }

    /**
     * 根据userid查询实名信息
     * @param userId
     * @return
     */
    @ApiOperation("根据userid查询实名信息")
    @GetMapping("/getByUserId/{userId}")
    public ResponseResult getByUserId(@PathVariable("userId") Integer userId){
        System.out.println(userId);
        return apRealnameService.getByUserId(userId);
    }

    /**
     * 根据用户id查询用户报名参加的活动列表
     * @param id
     * @return
     */
    @ApiOperation("根据用户id查询用户报名参加的活动列表")
    @PostMapping("/findAllAcByUser")
    public  ResponseResult findAllAcByUser(@RequestParam("id") Integer id){
        return apRealnameService.findAllAcByUser(id);
    }


}
